<style lang="stylus" scoped>
  .letter-space-12
    letter-spacing 12px
  .h-mb-50
    margin-bottom 50px
  .el-to-quasar-input-border
    width 100%
    border 1px solid $light
    &:hover
      border 1px solid $dark
  .h-td-maxwidth
    max-width 150px
  .label-sty
    display inline-block
    width 100px
  .fab-site
    right 32px
    top 38px
</style>

<template>
  <div>
    <q-card :class="isScroll? 'h-mb-50': ''">
      <q-card-section class="relative-position">
        <div class="text-h5 text-center">
          <span class="letter-space-12">询价单</span>
          <q-badge align="top" color="positive">已发布</q-badge>
        </div>
        <!-- <div class="absolute-right q-mt-md q-mr-md">
          <q-btn color="primary" label="返回" />
        </div> -->
        <q-fab color="accent" glossy icon="keyboard_arrow_down" direction="down" class="absolute fab-site">
          <q-fab-action color="amber" text-color="black" icon="mail" />
          <q-fab-action color="amber" text-color="black" icon="alarm" />
        </q-fab>
      </q-card-section>
      <q-separator inset />
      <q-card-section>
        <div class="row q-col-gutter-sm">
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
            <div style="font-size:17px">
              <strong>您好，</strong>
              <strong class="text-primary cursor-pointer">
                已选供应商列表
                <q-icon name="arrow_drop_down" size="20px" />
              </strong>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8" v-if="$q.screen.gt.xs"></div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4" v-if="$q.screen.gt.xs"></div>
          <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8">
            <div>
              <strong class="label-sty">询价主题：</strong>
              <span>{{ rfqForm.title }}</span>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4" v-if="$q.screen.gt.xs"></div>
          <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 row">
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
              <div>
                <strong class="label-sty">询价类型：</strong>
                <span>{{ rfqForm.type }}</span>
              </div>
            </div>
            <div :class="['col-xs-12 col-sm-6 col-md-6 col-lg-6', $q.screen.gt.xs? 'q-pl-sm': 'q-pt-sm']">
              <div>
                <strong class="label-sty">密封报价：</strong>
                <span>{{ rfqForm.isSeal }}</span>
              </div>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4" v-if="$q.screen.gt.xs"></div>
          <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 row">
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
              <div>
                <strong class="label-sty">需要报名：</strong>
                <span>否</span>
              </div>
            </div>
            <div v-if="rfqForm.isSignUp" :class="['col-xs-12 col-sm-6 col-md-6 col-lg-6', $q.screen.gt.xs? 'q-pl-sm': 'q-pt-sm']">
              <div>报名时间</div>
              <el-date-picker
                class="el-to-quasar-input-border"
                v-model="rfqForm.signUpTime"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间">
              </el-date-picker>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4" v-if="$q.screen.gt.xs"></div>
          <div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 row">
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
              <div>
                <strong class="label-sty">需要报价：</strong>
                <span>是</span>
              </div>
            </div>
            <div v-if="rfqForm.isQuote" :class="['col-xs-12 col-sm-6 col-md-6 col-lg-6', $q.screen.gt.xs? 'q-pl-sm': 'q-pt-sm']">
              <div>
                <strong class="label-sty">报价时间：</strong>
                <span>{{ rfqForm.quoteTime[0] }} - {{ rfqForm.quoteTime[1] }}</span>
              </div>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div>
              <strong class="label-sty">采购组织：</strong>
              <span>{{ rfqForm.title }}</span>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div>
              <strong class="label-sty">采购组：</strong>
              <span>{{ rfqForm.title }}</span>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div>
              <strong class="label-sty">采购执行人：</strong>
              <span>{{ rfqForm.title }}</span>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div>
              <strong class="label-sty">报价次数：</strong>
              <span>{{ rfqForm.title }}</span>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div>
              <strong class="label-sty">需要TR评审：</strong>
              <span>否</span>
            </div>
          </div>
        </div>
      </q-card-section>
      <q-card-section>
        <title-separator title="物料明细列表"/>
      </q-card-section>
      <q-card-section>
        <q-table
          class="bg-white no-shadow"
          bordered
          :data="data"
          :columns="columns"
          row-key="name"
          separator="cell"
          :visible-columns="visibleColumns"
        >
          <template v-slot:top-left="props">

          </template>
          <template v-slot:top-right="props">
            <q-select
              v-model="visibleColumns"
              multiple
              borderless
              dense
              options-dense
              :display-value="$t('显示列')"
              emit-value
              map-options
              :options="columns"
              option-value="name"
            />
            <q-btn
              flat round dense
              :icon="props.inFullscreen ? 'fullscreen_exit' : 'fullscreen'"
              @click="props.toggleFullscreen"
              class="q-ml-md"
            />
          </template>
          <template v-slot:header="props">
            <q-tr :props="props">
              <q-th v-for="col in props.cols" :key="col.name" :props="props">
                # {{ col.label }} #
              </q-th>
            </q-tr>
          </template>
          <template v-slot:body="props">
            <q-tr :props="props">
              <q-td key="name" :props="props">
                {{ props.row.name }}
                <q-btn dense round flat :icon="props.expand ? 'arrow_drop_up' : 'arrow_drop_down'" @click="props.expand = !props.expand" />
              </q-td>
              <q-td key="calories" :props="props">
                {{ props.row.calories }}
                <q-popup-edit v-model="props.row.calories" title="Update calories" buttons>
                  <q-input type="number" v-model="props.row.calories" dense autofocus />
                </q-popup-edit>
              </q-td>
              <q-td key="fat" :props="props">
                <div class="text-pre-wrap">{{ props.row.fat }}</div>
                <q-popup-edit v-model="props.row.fat">
                  <q-input type="textarea" v-model="props.row.fat" dense autofocus />
                </q-popup-edit>
              </q-td>
              <q-td key="carbs" :props="props">
                {{ props.row.carbs }}
                <q-popup-edit v-model="props.row.carbs" title="some text" buttons persistent>
                  <q-input type="number" v-model="props.row.carbs" dense autofocus hint="Use buttons to close" />
                </q-popup-edit>
              </q-td>
              <q-td key="protein" :props="props">
                <q-chip dense square label="成功类" color="positive" text-color="white" v-if="props.row.protein==='成功类'"/>
                <q-chip dense square label="失败类" color="negative" text-color="white" v-if="props.row.protein==='失败类'"/>
                <q-chip dense square label="预警类" color="warning" text-color="white" v-if="props.row.protein==='预警类'"/>
                <q-chip dense square label="未开始" color="grey" text-color="white" v-if="props.row.protein==='未开始'"/>
                <q-chip dense square label="待审核" color="grey" text-color="white" v-if="props.row.protein==='待审核'"/>
                <q-chip dense square label="信息类" color="info" text-color="white" v-if="props.row.protein==='信息类'"/>
              </q-td>
              <q-td key="sodium" :props="props" class="h-td-maxwidth ellipsis">
                {{ props.row.sodium }}
                <q-popup-edit v-model="props.row.sodium">
                  <q-input type="textarea" v-model="props.row.sodium" readonly dense autofocus counter />
                </q-popup-edit>
              </q-td>
              <q-td key="calcium" :props="props">{{ props.row.calcium }}</q-td>
              <q-td key="iron" :props="props">{{ props.row.iron }}</q-td>
            </q-tr>
            <q-tr v-show="props.expand" :props="props">
              <q-td colspan="100%">
                <div class="row justify-between">
                  <div class="col-6 q-my-sm">
                    <strong class="expand-row-label">创建人：</strong>
                    <span>{{ props.row.createUser }}</span>
                  </div>
                  <div class="col-6 q-my-sm">
                    <strong class="expand-row-label">创建时间：</strong>
                    <span>{{ props.row.createTime }}</span>
                  </div>
                  <div class="col-12 q-my-sm">
                    <strong class="expand-row-label">说 明：</strong>
                    <span>{{ props.row.remark }}</span>
                  </div>
                </div>
              </q-td>
            </q-tr>
          </template>
        </q-table>
      </q-card-section>
    </q-card>
    <transition
      appear
      enter-active-class="animated slideInUp"
      leave-active-class="animated fadeOut"
    >
      <q-toolbar v-if="isScroll" class="fixed-bottom bg-positive shadow-2 justify-end">
        <q-btn color="white" outline label="返回" />
      </q-toolbar>
    </transition>
    <q-scroll-observer @scroll="onScroll" />
  </div>
</template>

<script>
import TitleSeparator from 'components/LayoutComponents/TitleSeparator'

export default {
  components: {
    TitleSeparator
  },
  data () {
    return {
      isScroll: false,
      rfqForm: {
        sups: [],
        title: '3月份生产采购询价单',
        type: '产品',
        isSeal: '是',
        isSignUp: 0,
        signUpTime: [],
        isQuote: 1,
        quoteTime: ['2019-03-19 08:30', '2019-03-30 08:30']
      },
      supOptions: [
        {
          label: '浙江真奇',
          value: 'zjzq'
        },
        {
          label: '上海高歌',
          value: 'shgg'
        }
      ],
      typeOptions: [
        {
          label: '项目',
          value: 'xm'
        }
      ],
      isOptions: [
        {
          label: '是',
          value: 1
        },
        {
          label: '否',
          value: 0
        }
      ],
      // 表格
      dense: 'dense',
      visibleColumns: [
        'action',
        'name',
        'calories',
        'fat',
        'carbs',
        'protein',
        'sodium',
        'calcium',
        'iron'
      ],
      columns: [
        {
          name: 'name',
          required: true, // 当加入此属性时  visibleColumns 对当前字段无效
          label: '文字左对齐 - 示例',
          align: 'left',
          field: 'name'
        },
        { name: 'calories', align: 'center', label: 'pop编辑方式 - 示例', field: 'calories' },
        { name: 'fat', label: '可排序 - 示例', field: 'fat', sortable: true },
        { name: 'carbs', label: '数字右对齐 - 示例', field: 'carbs' },
        { name: 'protein', align: 'center', label: '状态chip - 示例', field: 'protein' },
        { name: 'sodium', label: '固定宽度-超出省略', field: 'sodium' },
        { name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) }
      ],
      data: [
        {
          name: 'Cupcake',
          calories: 305,
          fat: 3.7,
          carbs: 67,
          protein: '成功类',
          sodium: '从前有座山，山上有个庙，庙里有一个老和尚和一个小和尚，老和尚在给小和尚讲故事，讲什么故事呢？',
          calcium: '3%',
          iron: '8%',
          createTime: '2019-03-19',
          createUser: 'Yangdong.Hu',
          remark: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iusto temporibus, accusantium voluptatibus modi facilis ex beatae atque earum blanditiis voluptatem ea natus molestiae laborum velit.'
        },
        {
          name: 'Gingerbread',
          calories: 356,
          fat: 16.0,
          carbs: 49,
          protein: '待审核',
          sodium: 327,
          calcium: '7%',
          iron: '16%'
        },
        {
          name: 'Donut',
          calories: 452,
          fat: 25.0,
          carbs: 51,
          protein: '信息类',
          sodium: 326,
          calcium: '2%',
          iron: '22%'
        },
        {
          name: 'Lollipop',
          calories: 392,
          fat: 0.2,
          carbs: 98,
          protein: '失败类',
          sodium: 38,
          calcium: '0%',
          iron: '2%'
        },
        {
          name: 'Honeycomb',
          calories: 408,
          fat: 3.2,
          carbs: 87,
          protein: '预警类',
          sodium: 562,
          calcium: '0%',
          iron: '45%'
        },
        {
          name: 'Jelly bean',
          calories: 375,
          fat: 0.0,
          carbs: 94,
          protein: '成功类',
          sodium: 50,
          calcium: '0%',
          iron: '0%'
        },
        {
          name: 'KitKat',
          calories: 518,
          fat: 26.0,
          carbs: 65,
          protein: '未开始',
          sodium: 54,
          calcium: '12%',
          iron: '6%'
        }
      ]
    }
  },
  methods: {
    onScroll ({ position }) {
      if (position > 100) {
        this.isScroll = true
      } else {
        this.isScroll = false
      }
    }
  }
}
</script>
